package lore.miniwechat.web;

import lore.miniwechat.dto.BaseResponse;
import lore.miniwechat.entity.Chatrecord;
import lore.miniwechat.service.ChatrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/chatrecord")
public class ChatrecordController {

    @Autowired
    ChatrecordService service;

    //查询
    @GetMapping("/records")
    public List<Chatrecord> getRecords(){
        return service.getRecord();
    }

    //删除
    @DeleteMapping
    public BaseResponse deleteRecord(@PathVariable String id){
        service.deleteById(id);
        return BaseResponse.success();
    }

    //添加
    @PostMapping("/add")
    public BaseResponse insertRecord(@PathVariable Chatrecord chatrecord){
        service.insert(chatrecord);
        return BaseResponse.success();
    }
}
